<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div></div>
    <script>
        const gift = '50g的茶叶,清洗球'
        //1.把字符串拆分为数组
        const count = gift.split(',')
        console.log(count)
        //2.根据数组元素的个数，生成 对应的span标签
        const arr = count.map(function(ele){
            return `<span>【增品】${ele}</sapn>`
        }).join('')

        document.querySelector('div').innerHTML = arr
        // console.log(arr)
        //简便写法
        // document.querySelector('div').innerHTML = gift.split(',').map(ele => `<span>【增品】${ele}</sapn>`).join('')
    </script>
</body>
</html>